package com.keshan.controller;

import com.keshan.utils.DateUtil;
import com.keshan.utils.Msg;
import com.keshan.pojo.RemindToReply;
import com.keshan.pojo.RemindToReplyJson;
import com.keshan.service.RemindToReplyServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author keshan
 * @date 2022/10/21 - 12:57
 */
@CrossOrigin
@Controller
@RequestMapping("/remindtoreply")
public class RemindToReplyController {
    @Autowired
    RemindToReplyServices remindToReplyServices;

    @RequestMapping("/insertremindtoreply")
    @ResponseBody
    public Msg insertBySelectiveToRemindToReply(@RequestBody RemindToReplyJson remindToReplyJson){
        RemindToReply remindToReply = new RemindToReply();
        remindToReply.setAdvertId(remindToReplyJson.getAdvert_id());
        remindToReply.setAdvertText(remindToReplyJson.getAdvert_text());
        remindToReply.setAlertName(remindToReplyJson.getAlert_name());
        remindToReply.setDeviceType(remindToReplyJson.getDevice_type());
        remindToReply.setImei(remindToReplyJson.getImei());
        remindToReply.setReplyResult(remindToReplyJson.getReply_result());
        remindToReply.setReplyType(remindToReplyJson.getReply_type());
        remindToReply.setTimeBegin(DateUtil.StringToDate(remindToReplyJson.getTime_begin_str()));
        int result = remindToReplyServices.insertBySelectiveToRemindToReply(remindToReply);
        return Msg.success().add("result",result);
    }
}
